/***************************************************************************
 创建者: 华磊
 开始时间: 2020.8.14
 copyright: (C) 深圳市华友高科有限公司
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2020.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/
#ifndef MAPLOGIC_H
#define MAPLOGIC_H
#include <qvector.h>
#include <qstring.h>
#include <qmatrix.h>
#include "../CommunicateDelegate/globaldata.h"
/**
 * @brief The MapLogic class
 */
class MapLogic
{
public:
    /**
     * @brief MapLogic 构造函数
     */
    MapLogic();


public:
    int getOriginOffset(double &xOut,double &yOut,double &rOut);
    int setCarBorderAndOffset(std::vector<VehiclePosition> &carBorderOffsetIn);
<<<<<<< HEAD


=======


>>>>>>> dev
    /**
     * @brief getMapPgmFilePath　获取地图ｐｇ m　文件路径
     * @return
     */
    QString getMapPgmFilePath();
    /**
     * @brief reloadMap　加载地图
     * @param mapYamlPath
     * @return
     */
    int reloadMap(MapPropertyInfo infoIn);
//    /**
//     * @brief calculateCarPoint 计算车的边框点
//     * @param x
//     * @param y
//     * @param a
//     * @param xlist
//     * @param ylist
//     */
//    void calculateCarPoint(double x, double y, double a,QVector<double>& xlist,QVector<double>& ylist);
    /**
     * @brief calculateCarPoint
     * @param car_x_pix
     * @param car_y_pix
     * @param car_angle_degree
     * @param tmpMatrixOut
     */
    void calculateCarTransMatrix(double car_x_pix, double car_y_pix, double car_angle_degree,
                           QMatrix& tmpMatrixOut);
    void calculateDPointMatrix(double pictureWidth,double car_x_pix, double car_y_pix, double car_angle_degree,
                           QMatrix& tmpMatrixOut);
    /**
     * @brief calculateLaserTransMatrix　计算激光数据转移矩阵
     * @param car_x_pix　车的ｘ
     * @param car_y_pix 车的y
     * @param car_angle_degree 车的r
     * @param tmpMatrixOut
     * @return
     */
    int calculateLaserTransMatrix(double car_x_pix, double car_y_pix, double car_angle_degree, QMatrix &tmpMatrixOut);
    /**
     * @brief setCarProfile　设置车轮廓
     * @param frontLengthIn
     * @param backLengthIn
     * @param leftLengthIn
     * @param rightLengthIn
     * @return
     */
    int setCarProfile(double frontLengthIn ,double backLengthIn,
                      double leftLengthIn, double rightLengthIn);
    /**
     * @brief getMapWidth　获取地图宽
     * @return
     */
    double getMapWidth();
    /**
     * @brief getMapHeight　获取地图高
     * @return
     */
    double getMapHeight();
    /**
     * @brief getCarWidth　获取车宽
     * @return
     */
    double getCarWidth();
    /**
     * @brief getCarHeight　获取车高
     * @return
     */
    double getCarHeight();
    /**
     * @brief getMapResolution　获取地图分辨率
     * @return
     */
    double getMapResolution();

    /**
     * @brief translateScenePoint2WorldPoint　场景点转换世界点
     * @param x_in PIX
     * @param y_in PIX
     * @param a_in DEGREE
     * @param x_out M
     * @param y_out M
     * @param a_out DEGREE
     * @return
     */
    int translateScenePoint2WorldPoint(double x_in, double y_in,double a_in,
                                       double &x_out, double &y_out,double &a_out);
    /**
     * @brief translateWorldPoint2ScenePoint 世界点转换成屏幕点
     * @param x_in M
     * @param y_in M
     * @param a_in DEGREE
     * @param x_out PIX
     * @param y_out PIX
     * @param a_out DEGREE
     * @return
     */
    int translateWorldPoint2ScenePoint(double x_in, double y_in,double a_in,
                                       double &x_out, double &y_out,double &a_out);
    double translateToSceneLength(double worldLength);
//    int translateWorldPoint2ScenePoint_noBias(double x_in, double y_in,double a_in,
//                                       double &x_out, double &y_out,double &a_out);

private:
    int readYamlFile(QString yamlFile);//not used
    int readYamlFile(QString yamlFilePath,double &mapResolutionOut,
                             double &xOffsetOut,double &yOffsetOut,double &rOffsetOut,QString &imageNameOut);
    int getMapFileSize(QString pgmFile,double &width, double &heighth);


private:
    QString imageFilePath;

    double frontLength;
    double backLength;
    double leftLength;
    double rightLength;

    double mapResolution;
    double origin_x;
    double origin_y;
    double origin_a;//not use
    double mapWidth;
    double mapHeight;
};

#endif // MAPLOGIC_H
